Get some rest or making KDE more power efficient

This article is about saving the world. At least, give our small green planet a chance to last until it is eaten by this red dwarf called sun.

Motivated by an article and my recent purchase of a new laptop, I went looking for some reasons for the mismatch in power usage of KDE vs the other DEs. Although is was not worried about the differences in memory usage (others have commented on measuring memory usage correctly in depth), the increase of power usage between the beginning of the benchmark and the end struck me. As the system is idle in both cases, power usage should be the same, if not, there is something going on.

The fact something went wrong came very prominent after I left the laptop idling for some hours, only with kopete running in the background. After I came back, the CPU was working at full load. top revealed the process responsible for the high load, plasma-destop. Using strace it became obvious it was spending its whole time in the main event loop, caused by an insane number of timeouts (about every 10 milliseconds …).

The first part was easy, the second was a little bit more difficult. First, I tried to find the responsible timer using gdb, but after some time it became evident not a single timer was causing this, but a large number of different timers (the object address changed every time it hit the breakpoint in the event loop).

Fortunately, I stumbled over a small patch which is part of Qt4 as delivered by openSUSE (and probably others, haven’t checked). This patch prints the name of the object, or at least its class name, responsible for a timeout which has occurred, and the hierarchy of parents.

After restarting plasma-desktop with QT_DEBUG_TIMER=1 set (which enables the logging of timeouts), at first there was nothing suspicious. After some this changed, there was an ever increasing number of events like the following:
activating 5000 ms timer for Application Notifications

Every time a new notification popup opened, a new timer was started, but it was newer killed.

If you are using openSUSE, call yourself lucky, because the patch has been included in the KDE 4.4 packages for some time now, else point your distributor to KDE bug #230740 (patch provided).

Although this is IMHO the most critical bug, there are a few more timer related ones. Stay tuned …

Hinterlasse einen Kommentar